@extends('frontend/layouts/bootstrap')

@section('content')
<div>
    <span style="font-size: 31.5px;  line-height: 40px;  margin: 10px 0;  font-family: inherit;  font-weight: bold;  color: inherit;  text-rendering: optimizelegibility;  -webkit-margin-before: 0.83em;  -webkit-margin-after: 0.83em;  -webkit-margin-start: 0px;  -webkit-margin-end: 0px;"> Edit PurchaseCar</span>
    {{ link_to_route('car_balance.main.car_list', 'Return to Purchase Car list', null, array('class' => 'btn btn-info', 'style' => 'float: right; margin: 10px 0;')) }}
    {{ link_to_route('car_balance.car.car_show', 'Back to PurchaseCar show', $purchase_car->id, array('class' => 'btn btn-info', 'style' => 'float: right; margin: 10px 10px;')) }}
</div>

{{ Form::open(array('route' => array('car_balance.car.car_edit', $purchase_car->id), 'class' => 'form-horizontal', 'files' => true)) }}
<h4>Үндсэн мэдээлэл @if (empty($customer)) @if ($purchase_car->purchase_car_comment) <div style="float:right;font-weight:normal;font-size: medium;color:green;padding:2px 2px 2px 20px;font-size: medium;max-width:900px;">{{ $purchase_car->purchase_car_comment }}</div> @endif @endif </h4>
<table class="table table-bordered">
    <thead style="background-color: #f0f0f0;">
    <th>Price set</th>
    <th>Auction type</th>
    <th>Auction</th>
    <th>Service company</th>
    <th>Container type</th>
    </thead>

    <tr>
        <td{{ $errors->first('customer_id', ' class="control-group error"') }}>
        {{ Form::select('customer_id', $customer_list, Input::old('customer_id', $purchase_car->customer_id), array('data-placeholder' => 'Customer', 'class' => 'span2', 'name' => 'customer_id')) }}
        {{ $errors->first('customer_id', '<span class="help-inline">:message</span>') }}
        </td>
        <td{{ $errors->first('car_auction_type', ' class="control-group error"') }}>
            {{ Form::select('car_auction_type', $car_auction_type_list, Input::old('car_auction_type', $purchase_car->auction_type), array('data-placeholder' => 'Auction Type', 'class' => 'span2', 'name' => 'car_auction_type')) }}
            {{ $errors->first('car_auction_type', '<span class="help-inline">:message</span>') }}
        </td>
        <td{{ $errors->first('car_auction_id', ' class="control-group error"') }}>
        {{ Form::select('car_auction_id', $car_auction_list, Input::old('car_auction_id', $purchase_car->auction_name), array('data-placeholder' => 'Car Auction', 'class' => 'span2', 'name' => 'car_auction_id')) }}
        {{ $errors->first('car_auction_id', '<span class="help-inline">:message</span>') }}
        </td>
        <td{{ $errors->first('service_company_id', ' class="control-group error"') }}>
        {{ Form::select('service_company_id', $service_company_list, Input::old('service_company_id', $purchase_car->service_company_id), array('data-placeholder' => 'Service Company', 'class' => 'span2', 'name' => 'service_company_id')) }}
        {{ $errors->first('service_company_id', '<span class="help-inline">:message</span>') }}
        </td>
        <td{{ $errors->first('container_port', ' class="control-group error"') }}>
        {{ Form::select('container_port', $container_ports, Input::old('container_port', $purchase_car->container_port), array('data-placeholder' => 'Container port', 'class' => 'span2', 'name' => 'container_port')) }}
        {{ $errors->first('container_port', '<span class="help-inline">:message</span>') }}
        </td>
    </tr>
</table>


<h4>Үндсэн мэдээлэл</h4>
<table class="table table-bordered">
    <thead style="background-color: #f0f0f0;">
    <th title="Date">日付</th>
    <th title="Exhibit number">出品番号</th>
    <th title="Car model">車種</th>
    <th title="Model year">年式 / 年月</th>
    <th title="Chassis number">車体番号</th>
    <th title="Number plate flag">Number plate</th>
    <th title="Auction sheet">オークションシート</th>
    </thead>

    <tr>
        <td{{ $errors->first('purchase_date', ' class="control-group error"') }}>
        <input class="datepicker input-medium" placeholder="Purchase Date" title="Purchase Date" name="purchase_date" type="text" value="{{ Input::old('purchase_date', $purchase_car->purchase_date) }}">
        {{ $errors->first('purchase_date', '<span class="help-inline">:message</span>') }}
        </td>
        <td{{ $errors->first('lot_no', ' class="control-group error"') }}>
        <input class="input-small" placeholder="Exhibit Number" title="Lot Number" name="lot_no" type="text" value="{{ Input::old('lot_no', $purchase_car->lot_no) }}">
        {{ $errors->first('lot_no', '<span class="help-inline">:message</span>') }}
        </td>
        <td{{ $errors->first('car_maker', ' class="control-group error"') }}>
        {{ Form::select('car_maker', $car_makers, Input::old('car_maker', $purchase_car->car_maker), array('class'=>'input-medium', 'id' => 'car_maker')) }}
        {{ $errors->first('car_maker', '<span class="help-inline">:message</span>') }}
        <div id="car_name"></div>
        </td>
        <td{{ $errors->first('car_year', ' class="control-group error"') }} {{ $errors->first('car_year_month', ' class="control-group error"') }}>
        <input class="input-small" placeholder="Model Year" title="Model Year" name="car_year" type="text" value="{{ Input::old('car_year', $purchase_car->car_year) }}" data-provide="typeahead" data-source='[@for($i=1990;$i<2013;$i++)"{{$i}}",@endfor"2014"]'>
        <input class="input-small" placeholder="Year month" title="Year month" name="car_year_month" type="text" value="{{ Input::old('car_year_month', $purchase_car->car_year_month) }}">
        {{ $errors->first('car_year', '<span class="help-inline">:message</span>') }} {{ $errors->first('car_year_month', '<span class="help-inline">:message</span>') }}
        </td>
        <td{{ $errors->first('chasis_no', ' class="control-group error"') }}>
        <input class="" placeholder="Chasis Number" title="Chasis Number" name="chasis_no" type="text" value="{{ Input::old('chasis_no', $purchase_car->chasis_no) }}">
        {{ $errors->first('chasis_no', '<span class="help-inline">:message</span>') }}
        </td>
        <td{{ $errors->first('number_plate_flag', ' class="control-group error"') }}>
        <input id="number_plate_flag" placeholder="チェック" type="checkbox" class="input-small" style="margin-bottom: 5px; margin-right: 5px;" name="number_plate_flag" {{  $purchase_car->number_plate_flag ? 'checked' : '' }}/>
        {{ $errors->first('number_plate_flag', '<span class="help-inline">:message</span>') }}
        </td>
        <td>
            <div class="fileupload fileupload-new" data-provides="fileupload">
                <div id="auction_sheet_upload" class="input-append">
                    <div class="uneditable-input span3">
                        @if ( $purchase_car->auction_sheet_upload_flag )
                            <a target="_blank" href="{{route('car_balance.main.display', array('type'=>'auction', 'file'=>'auction_sheet_'.$purchase_car->chasis_no.'.pdf'))}}" title="{{ $purchase_car->car_year }}-{{ $purchase_car->car_name }}-{{ $purchase_car->chasis_no; }}">
                                <i class="icon-zoom-in icon-white"></i></a><span class="fileupload-preview"></span>
                        @else
                            <i class="icon-file fileupload-exists"></i>
                            <span class="fileupload-preview"></span>
                        @endif
                    </div>
                    <div>
                    <span class="btn btn-file">
                        <span class="fileupload-new">Select file</span>
                        <span class="fileupload-exists">Change</span>
                        <input name="auction_sheet_upload" type="file" />
                    </span></br>
                        <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
                    </div>
                </div>
            </div>
        </td>
    </tr>
</table>

<h4>Payments</h4>
<table class="table table-bordered">
    <thead style="background-color: #f0f0f0;">
    <th title="Purchase price">購入額</th>
    <th title="VAT (%)">消費税 (%)</th>
    <th title="Recycle Amount">リサイクル</th>
    <th title="Auction commission">落札料</th>
    <th title="Car tax amount">自動車税</th>
    <th title="Transport fee">Transport</th>
    <th title="Drayage fee">Drayage</th>
    <th title="Vanning">Vanning</th>
    <th title="Customs">Customs</th>
    <th title="Others">その他</th>
    <th title="BL">BL</th>
    </thead>

    <tr>
        <td>
            <input class="input-small" placeholder="Purchase Price" title="Purchase Price" name="purchase_price" type="text" id="purchase_price" value="{{ $purchase_car->purchase_price }}">
        </td>
        <td>
            <select name="vat_percent" id="vat_percent" class="input-small">
                <option value="8" {{ Input::old('vat_percent') == '8' || $purchase_car->vat_percent == 8 ? 'selected' : '' }}>8 %</option>
                <option value="5" {{ Input::old('vat_percent') == '5' || $purchase_car->vat_percent == 5 ? 'selected' : '' }}>5 %</option>
                <option value="3" {{ Input::old('vat_percent') == '3' || $purchase_car->vat_percent == 3 ? 'selected' : '' }}>3 %</option>
                <option value="0" {{ Input::old('vat_percent') == '0' || $purchase_car->vat_percent == 0 ? 'selected' : '' }}>0 %</option>
            </select>
        </td>
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'recycle_amount', 'value' => $purchase_car->recycle_amount))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'auction_commission', 'value' => $purchase_car->auction_commission))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'car_tax_amount', 'value' => $purchase_car->car_tax_amount))
        <td>
            <input class="input-mini" placeholder="Transfer fee 1" title="Transfer fee 1" name="transfer_fee_1" type="text" id="transfer_fee_1" value="{{$purchase_car->transfer_fee_1}}">
            <br/><input class="input-mini" placeholder="Transfer fee 2" title="Transfer fee 2" name="transfer_fee_2" type="text" id="transfer_fee_2" value="{{$purchase_car->transfer_fee_2}}">
        </td>
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'drayage', 'value' => $purchase_car->drayage, 'class' => 'input-mini'))
        <td>
            <input class="input-mini" placeholder="Vanning fee 1" title="Vanning fee 1" name="vanning_1" type="text" id="vanning_1" value="{{$purchase_car->vanning_1}}">
            <br/><input class="input-mini" placeholder="Vanning fee 2" title="Vanning fee 2" name="vanning_2" type="text" id="vanning_2" value="{{$purchase_car->vanning_2}}">
        </td>
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'customs', 'value' => $purchase_car->customs, 'class' => 'input-mini'))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'others', 'value' => $purchase_car->others))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bl_fee', 'value' => $purchase_car->bl_fee, 'class' => 'input-mini'))
    </tr>
</table>

<div style="@if ( Sentry::getUser()->hasAccess('operator')) display:none; @endif">
<h4>Bill</h4>
<ul class="nav nav-tabs" id="bill_info">
    <li class="{{ $purchase_car->bill_type == '1' ? 'active' : '' }}"><a href="#bill_type_1" data-toggle="tab">Bill type 1</a></li>
    <li class="{{ $purchase_car->bill_type == '2' ? 'active' : '' }}"><a href="#bill_type_2" data-toggle="tab">Bill type 2</a></li>
    <li class="{{ $purchase_car->bill_type == '3' ? 'active' : '' }}"><a href="#bill_type_3" data-toggle="tab">Bill type 3</a></li>
    <li class="{{ $purchase_car->bill_type == '4' ? 'active' : '' }}"><a href="#bill_type_4" data-toggle="tab">Bill type 4</a></li>
    <li class="{{ $purchase_car->bill_type == '0' ? 'active' : '' }} {{ $purchase_car->bill_type ? '' : 'active' }}"><a href="#bill_type_0" data-toggle="tab">Bill type 0</a></li>
</ul>

<div class="tab-content">
    <div class="tab-pane {{ $purchase_car->bill_type == '1' ? 'active' : '' }}" id="bill_type_1">
        <table class="table table-bordered" id="billDetailed">
            <thead style="background-color: #f0f0f0;">
            <th title="Price">Price</th>
            <th title="VAT (%)">VAT (%)</th>
            <th title="Transport">Transport</th>
            <th title="Commission">Commission</th>
            </thead>
            <tr>
                <td>
                    <input class="input-small" placeholder="Bill Price" title="Bill Price" name="bill_price_1" type="text" id="bill_price_1" value="{{ $purchase_car->bill_price }}">
                </td>
                <td>
                    <select name="bill_vat_1" id="bill_vat_1" class="input-small">
                        <option value="8" {{ Input::old('bill_vat') == '8' || $purchase_car->bill_vat == 8 ? 'selected' : '' }}>8 %</option>
                        <option value="5" {{ Input::old('bill_vat') == '5' || $purchase_car->bill_vat == 5 ? 'selected' : '' }}>5 %</option>
                        <option value="3" {{ Input::old('bill_vat') == '3' || $purchase_car->bill_vat == 3 ? 'selected' : '' }}>3 %</option>
                        <option value="0" {{ Input::old('bill_vat') == '0' || $purchase_car->bill_vat == 0 ? 'selected' : '' }}>0 %</option>
                    </select>
                </td>
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_transport_fee_1', 'value'=>$purchase_car->bill_transport_fee))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_commission_1', 'value'=>$purchase_car->bill_commission))
                <input name="active_tab_1" type="hidden" id="active_tab_1" value="{{ $purchase_car->bill_type == '1' ? '1' : '0' }}">
            </tr>
        </table>
    </div>

    <div class="tab-pane {{ $purchase_car->bill_type == '2' ? 'active' : '' }}" id="bill_type_2">
        <table class="table table-bordered" id="billDetailed">
            <thead style="background-color: #f0f0f0;">
            <th title="Price">Price</th>
            <th title="VAT (%)">VAT (%)</th>
            <th title="Auction commission">落札料</th>
            <th title="Transport">Transport</th>
            <th title="Vanning">Vanning</th>
            <th title="Commission">Commission</th>
            </thead>
            <tr>
                <td>
                    <input class="input-small" placeholder="Bill Price" title="Bill Price" name="bill_price_2" type="text" id="bill_price_2" value="{{ $purchase_car->bill_price }}">
                </td>
                <td>
                    <select name="bill_vat_2" id="bill_vat_2" class="input-small">
                        <option value="8" {{ Input::old('bill_vat') == '8' || $purchase_car->bill_vat == 8 ? 'selected' : '' }}>8 %</option>
                        <option value="5" {{ Input::old('bill_vat') == '5' || $purchase_car->bill_vat == 5 ? 'selected' : '' }}>5 %</option>
                        <option value="3" {{ Input::old('bill_vat') == '3' || $purchase_car->bill_vat == 3 ? 'selected' : '' }}>3 %</option>
                        <option value="0" {{ Input::old('bill_vat') == '0' || $purchase_car->bill_vat == 0 ? 'selected' : '' }}>0 %</option>
                    </select>
                </td>
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_rakusatu_2', 'value'=>$purchase_car->bill_rakusatu))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_transport_fee_2', 'value'=>$purchase_car->bill_transport_fee))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_vanning_2', 'value'=>$purchase_car->bill_vanning))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_commission_2', 'value'=>$purchase_car->bill_commission))
                <input name="active_tab_2" type="hidden" id="active_tab_2" value="{{ $purchase_car->bill_type == '2' ? '1' : '0' }}">
            </tr>
        </table>
    </div>
    <div class="tab-pane {{ $purchase_car->bill_type == '3' ? 'active' : '' }}" id="bill_type_3">
        <table class="table table-bordered" id="billDetailed">
            <thead style="background-color: #f0f0f0;">
            <th title="Price">Price</th>
            <th title="Commission">Commission</th>
            </thead>
            <tr>
                <td>
                    <input class="input-small" placeholder="Bill Price" title="Bill Price" name="bill_price_3" type="text" id="bill_price_3" value="{{ $purchase_car->bill_price }}">
                </td>
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_commission_3', 'value'=>$purchase_car->bill_commission))
                <input name="active_tab_3" type="hidden" id="active_tab_3" value="{{ $purchase_car->bill_type == '3' ? '1' : '0' }}">
            </tr>
        </table>
    </div>
    <div class="tab-pane {{ $purchase_car->bill_type == '4' ? 'active' : '' }}" id="bill_type_4">
        <table class="table table-bordered" id="billDetailed">
            <thead style="background-color: #f0f0f0;">
            <th title="Price">Price</th>
            <th title="VAT (%)">VAT (%)</th>
            <th title="Recycle">Recycle</th>
            <th title="Auction commission">落札料</th>
            <th title="Transport">Transport</th>
            <th title="Vanning">Vanning</th>
            <th title="Others">Others</th>
            <th title="Commission">Commission</th>
            </thead>
            <tr>
                <td>
                    <input class="input-small" placeholder="Bill Price" title="Bill Price" name="bill_price_4" type="text" id="bill_price_4" value="{{ $purchase_car->bill_price }}">
                </td>
                <td>
                    <select name="bill_vat_4" id="bill_vat_4" class="input-small">
                        <option value="8" {{ Input::old('bill_vat') == '8' || $purchase_car->bill_vat == 8 ? 'selected' : '' }}>8 %</option>
                        <option value="5" {{ Input::old('bill_vat') == '5' || $purchase_car->bill_vat == 5 ? 'selected' : '' }}>5 %</option>
                        <option value="3" {{ Input::old('bill_vat') == '3' || $purchase_car->bill_vat == 3 ? 'selected' : '' }}>3 %</option>
                        <option value="0" {{ Input::old('bill_vat') == '0' || $purchase_car->bill_vat == 0 ? 'selected' : '' }}>0 %</option>
                    </select>
                </td>
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_recycle_4', 'value'=>$purchase_car->bill_recycle))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_rakusatu_4', 'value'=>$purchase_car->bill_rakusatu))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_transport_fee_4', 'value'=>$purchase_car->bill_transport_fee))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_vanning_4', 'value'=>$purchase_car->bill_vanning))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_others_4', 'value'=>$purchase_car->bill_others))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_commission_4', 'value'=>$purchase_car->bill_commission))
                <input name="active_tab_4" type="hidden" id="active_tab_4" value="{{ $purchase_car->bill_type == '4' ? '1' : '0' }}">
            </tr>
        </table>
    </div>

    <div class="tab-pane {{ $purchase_car->bill_type == '0' ? 'active' : '' }} {{ $purchase_car->bill_type ? '' : 'active' }}" id="bill_type_0">
        <table class="table table-bordered" id="billDetailed">
            <thead style="background-color: #f0f0f0;">
            <th title="Price">Price</th>
            <th title="VAT (%)">VAT (%)</th>
            <th title="Recycle">Recycle</th>
            <th title="Auction commission">落札料</th>
            <th title="Transport">Transport</th>
            <th title="Vanning">Vanning</th>
            <th title="Others">Others</th>
            <th title="Commission">Commission</th>
            </thead>
            <tr>
                <td>
                    <input class="input-small" placeholder="Bill Price" title="Bill Price" name="bill_price_0" type="text" id="bill_price_0" value="{{ $purchase_car->bill_price }}">
                </td>
                <td>
                    <select name="bill_vat_0" id="bill_vat_0" class="input-small">
                        <option value="8" {{ Input::old('bill_vat') == '8' || $purchase_car->bill_vat == 8 ? 'selected' : '' }}>8 %</option>
                        <option value="5" {{ Input::old('bill_vat') == '5' || $purchase_car->bill_vat == 5 ? 'selected' : '' }}>5 %</option>
                        <option value="3" {{ Input::old('bill_vat') == '3' || $purchase_car->bill_vat == 3 ? 'selected' : '' }}>3 %</option>
                        <option value="0" {{ Input::old('bill_vat') == '0' || $purchase_car->bill_vat == 0 ? 'selected' : '' }}>0 %</option>
                    </select>
                </td>
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_recycle_0', 'value'=>$purchase_car->bill_recycle))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_rakusatu_0', 'value'=>$purchase_car->bill_rakusatu))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_transport_fee_0', 'value'=>$purchase_car->bill_transport_fee))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_vanning_0', 'value'=>$purchase_car->bill_vanning))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_others_0', 'value'=>$purchase_car->bill_others))
                @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_commission_0', 'value'=>$purchase_car->bill_commission))
                <input name="active_tab_0" type="hidden" id="active_tab_0" value="{{ $purchase_car->bill_type == '0' ? 'active' : '' }} {{ $purchase_car->bill_type ? '' : 'active' }}">
            </tr>
        </table>
    </div>
</div>
</div>
<!--<h4>Bill</h4>
<label for="bill_lump_flag"><input type="checkbox" name="bill_lump_flag" {{ Input::old('bill_lump_flag') ? 'checked' : '' }} id="bill_lump_flag"/>Bill -ийн багцалсан үнийн дүн оруулах</label>
<table class="table table-bordered" id="billDetailed">
    <thead style="background-color: #f0f0f0;">
    <th title="Price">Price</th>
    <th title="VAT">VAT</th>
    <th title="Recycle">Recycle</th>
    <th title="Auction commission">Auction commission</th>
    <th title="Transport">Transport</th>
    <th title="Vanning">Vanning</th>
    <th title="Others">Others</th>
    <th title="Commission">Commission</th>
    </thead>

    <tr>
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_price', 'value' => $purchase_car->bill_price))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_vat', 'value' => $purchase_car->bill_vat))
        <td>
            <select name="bill_vat" id="bill_vat" class="input-small">
                <option value="5" {{ Input::old('bill_vat') == '5' ? 'selected' : '' }}>5 %</option>
                <option value="8" {{ Input::old('bill_vat') == '8' ? 'selected' : '' }}>8 %</option>
                <option value="0" {{ Input::old('bill_vat') == '0' ? 'selected' : '' }}>0 %</option>
            </select>
        </td>
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_recycle', 'value' => $purchase_car->bill_recycle))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_rakusatu', 'value' => $purchase_car->bill_rakusatu))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_transport_fee', 'value' => $purchase_car->bill_transport_fee))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_vanning', 'value' => $purchase_car->bill_vanning))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_others', 'value' => $purchase_car->bill_others))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_commission', 'value' => $purchase_car->bill_commission))
    </tr>
</table>
<table class="table table-bordered" id="billLump">
    <thead style="background-color: #f0f0f0;">
    <th title="Total amount">Total amount</th>
    </thead>

    <tr>
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'bill_total_amount', 'value'=>$purchase_car->bill_total_amount))
    </tr>
</table>
-->
<h4>Контайнерын мэдээлэл</h4>
<table class="table table-bordered">
    <thead style="background-color: #f0f0f0;">
    <th title="Container id">Container id</th>
    <th title="Container id">Container no</th>
    <th title="Container date">Container date</th>
    </thead>

    <tr>
        <td{{ $errors->first('container_id', ' class="control-group error"') }}>
        <input class="input-medium" placeholder="Container id" title="Container id" name="container_id" type="text" value="{{ Input::old('container_id', $purchase_car->container_id) }}">
        {{ $errors->first('container_id', '<span class="help-inline">:message</span>') }}
        </td>
        <td{{ $errors->first('container_no', ' class="control-group error"') }}>
        <input class="input-medium" placeholder="Container no" title="Container no" name="container_no" type="text" value="{{ Input::old('container_no', $purchase_car->container_no) }}">
        {{ $errors->first('container_no', '<span class="help-inline">:message</span>') }}
        </td>
        <td{{ $errors->first('container_date', ' class="control-group error"') }}>
        <input class="datepicker input-medium" placeholder="Container date" title="Container date" name="container_date" type="text" value="{{ Input::old('container_date', $purchase_car->container_date) }}">
        {{ $errors->first('container_date', '<span class="help-inline">:message</span>') }}
        </td>
    </tr>
</table>

<button type="reset" class="btn btn-large btn-default">Reset</button>
<button type="submit" class="btn btn-large btn-success"><i class="icon-plus icon-white"></i> Хадгалах</button> &nbsp;&nbsp;

{{  Form::close() }}
@stop

@section('pagestyles')
    <link rel="stylesheet" type="text/css" href={{ asset('assets/bootstrap-fileupload/fileupload.css') }} />
    <link rel="stylesheet" type="text/css" href={{ asset('assets/bootstrap-datepicker/datepicker.css') }} />
@stop
@section('pagescripts')
    <script type="text/javascript" src={{ asset('assets/bootstrap-fileupload/fileupload.js') }}></script>
    <script type="text/javascript" src={{ asset('assets/bootstrap-datepicker/datepicker.js') }}></script>
    <script type="text/javascript" >
        $(document).ready(function(){
            if($('input[name=purchase_date]').val() == '') {
                var d = new Date();

                var month = d.getMonth()+1;
                var day = d.getDate();

                var output = d.getFullYear() + '-' +
                    (month<10 ? '0' : '') + month + '-' +
                    (day<10 ? '0' : '') + day;

                $('input[name=purchase_date]').val(output);
            }

            $('#bill_lump_flag').on('change', function(e){
                if(this.checked) {
                    $('#billDetailed').hide();
                    $('#billLump').show();
                } else {
                    $('#billDetailed').show();
                    $('#billLump').hide();
                }
            });

            if($('#bill_lump_flag').attr('checked')) {
                $('#billDetailed').hide();
                $('#billLump').show();
            } else {
                $('#billDetailed').show();
                $('#billLump').hide();
            }

            if($('#car_maker').val().length){
                var model = '{{ $purchase_car->car_name }}';
                var e = document.getElementById("car_maker");
                var strUser = e.options[e.selectedIndex].value;
                $.get('{{ route('car_balance.car.getCarName') }}?maker='+strUser+'&model='+model, function(d){
                    $('#car_name').html(d);
                })
            }

            $('select[name=car_maker]').on('change', function(e){
                $.get('{{ route('car_balance.car.getCarName') }}?maker='+this.value, function(d){
                    $('#car_name').html(d);
                })
                console.log(this.value);
            });

            $(function() {
                $( ".datepicker" ).datepicker({
                    defaultDate: "+0d",
                    format: "yyyy-mm-dd",
                    autoclose: true
                });
            });
            $("#purchase_price").each(function(i){
                $(this).change(function () {
                    document.getElementById("bill_price_1").value=document.getElementById("purchase_price").value;
                    document.getElementById("bill_price_2").value=document.getElementById("purchase_price").value;
                    document.getElementById("bill_price_3").value=document.getElementById("purchase_price").value;
                    document.getElementById("bill_price_4").value=document.getElementById("purchase_price").value;
                    document.getElementById("bill_price_0").value=document.getElementById("purchase_price").value;
                });
            });
            $("#vat_percent").each(function(i){
                $(this).change(function () {
                    document.getElementById("bill_vat_1").value=document.getElementById("vat_percent").value;
                    document.getElementById("bill_vat_2").value=document.getElementById("vat_percent").value;
                    document.getElementById("bill_vat_4").value=document.getElementById("vat_percent").value;
                    document.getElementById("bill_vat_0").value=document.getElementById("vat_percent").value;
                });
            });

            $(function() {
                var activeTab = null;
                $('a[data-toggle="tab"]').on('shown', function (e) {
                    activeTab = e.target.href;
                    bill_type = activeTab.substring(activeTab.length-1);
                    setActiveTab(bill_type);
                })
                function setActiveTab(bill_type) {
                    for ( var i = 0; i < 5; i++ ) {
                        if (i == bill_type) {
                            document.getElementById("active_tab_" + bill_type).value = 1;
                        } else {
                            document.getElementById("active_tab_" + i).value = 0;
                        }
                    }
                }
            });

        });
    </script>
    @stop